import * as express from 'express'
import apiSv from '../../services/apiSV';
import teacherlistSV from '../../services/teacherlistSV';

let router = express.Router()

router.get('/gettypeList', async (req, res, next) => {
  try {
    let data = await apiSv(req.api.v4.get, {
      action: 'course.instructor.typelist',
      sessionKey: req.t,
      companyID: req.companyId,
      pageIndex: req.query.page || 1,
      pageSize: 9999,
    })
    return res.json({ status: true, data: data.data })
  } catch (e) {
    return next(e)
  }
})
router.get('/getList', async (req, res, next) => {
  try {
    let data = await apiSv(req.api.v4.get, {
      action: 'course.instructor.list',
      sessionKey: req.t,
      companyID: req.companyId,
      pageIndex: req.query.page || 1,
      pageSize: 9999,
      agentStatus:1
    })
    return res.json({ status: true, data: data.data })
  } catch (e) {
    return next(e)
  }
})



router.get("/getSurveyInfo", async (req, res, next) => {
  try {
    let data = await teacherlistSV.getPersonalSurveyInfo(req)
    return res.json({ status: true, data })
  } catch (e) {
    return next(e)
  }
})


router.post("/commitSurvey", async (req, res, next) => {
  try {
    let data = await apiSv(req.api.v4.post, {
      action: 'corpsurvey.surveyuseranswer.set',
      sessionKey: req.t,
      companyID: req.companyId,
      surveyID: req.body.surveyId,
      Answer: req.body.answer,
      Memo: '',
      Duration: req.body.duration,
    })
    return res.json({ status: true })
  } catch (e) {
    return next(e)
  }
})

export default router
